package com.starry.db.core.enums;

import cn.hutool.core.util.ObjUtil;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Description 通用状态枚举：启用禁用
 * @Author xiaoke
 *
 */
@Getter
@AllArgsConstructor
public enum DBEnableDisableStatusEnum {
    ENABLE(1, "启用"),

    DISABLE(0, "禁用");

    @EnumValue // 标注该字段是数据库里的字段
    private final Integer code;

    @JsonValue // 标注该字段要开启自定义序列化返回值
    private final String name;

    public static boolean isEnable(Integer status) {
        return ObjUtil.equal(ENABLE.code, status);
    }

    public static boolean isDisable(Integer status) {
        return ObjUtil.equal(DISABLE.code, status);
    }

    @Override
    public String toString() {
        return this.name;
    }
}
